package model;

import java.io.Serializable;

@SuppressWarnings("serial")
public class ShortInformationBean implements Comparable<Object>, Serializable {

	private String id;
	private String name;
	private String description;
	
	public ShortInformationBean(String id, String name, String description) {
		this.id = id;
		this.name = name;
		this.description = description;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ShortInformationBean other = (ShortInformationBean) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "ShortInformationBean [id=" + id + ", name=" + name + ", description=" + description + "]";
	}
	
	//Methods with capitalized letters added to be used by {@link AliasToBeanResultTransformer}
	public void setID(String id) {
		this.id = id;
	}

	public void setNAME(String name) {
		this.name = name;
	}

	public void setDESCRIPTION(String description) {
		this.description = description;
	}

	@Override
	public int compareTo(Object o) {
		if (o == null) {
			return 1;
		}
		String oName = ((ShortInformationBean)o).getName();
		if (oName == null) {
			oName = "";
		}
		String cName = (getName() != null) ? getName() : "";
		int i = cName.compareTo(oName);
		if (i != 0) {
			return i;
		}
		String oDescr = ((ShortInformationBean)o).getDescription();
		if (oDescr == null) {
			oDescr = "";
		}
		String cDescr = (getDescription() != null) ? getDescription() : "";
		return cDescr.compareTo(oDescr);
	}
}
